package com.lu.pojo.base;

import java.util.*;

/**
 * @Author:luzhenfang
 * @Date:2020 3 10
 */
public class Month {
    public static void main(String[] args) {
        // 1 3 5 7 8 10 12
        // 4 6 9 11
        // leap
        // 月份 flag
        Map<Integer, Integer> map = new HashMap<>();
        List<Integer> $30days = Arrays.asList(4,6,9,11);
        Scanner sc = new Scanner(System.in);

        System.out.print("请输入年:");
        int year=sc.nextInt();
        System.out.print("请输入月:");
        int mon=sc.nextInt();
        System.out.print("请输入日:");
        int day=sc.nextInt();


        for (int i=0;i<12;i++){
            // 处理 30 天的
            if ($30days.contains(i+1)){
                map .put(i+1,30);
            // 处理2月
            }else if(i+1==2){
                int m;
                m = isLeap(year)?29:28;
                map.put(2,m);
            }else{
                map.put(i+1,31);
            }
        }
        System.out.println(map);
        int count=0;
        for (Map.Entry<Integer,Integer>entry : map.entrySet()){
            if (entry.getKey()<=mon){
                count+=entry.getValue();
            }else{
                break;
            }
        }
        count+=day;
        System.out.printf("是该年的第%d天",count);

    }
    // 判断是否是润年
    public static boolean isLeap(int year) {
        return (year % 4 == 0 && year % 100 != 0 || year % 400 == 0);
    }
}
